package buka.oversea.aeron5.config;

import io.aeron.cluster.client.AeronCluster;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AeronClientConfig {

    @Value("${aeron.ingress:localhost:9000}")
    private String ingressEndpoint;

    @Bean(destroyMethod = "close")
    public AeronCluster clusterClient() {
        return AeronCluster.connect(
                new io.aeron.cluster.client.AeronCluster.Context()
                        .aeronDirectoryName("aeron-client")
                        .ingressChannel("aeron:udp?endpoint=" + ingressEndpoint)
        );
    }
}
